<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//单纯的后台管理
Route::get('/', function () {
    return redirect()->route('index');
})->middleware('auth');

Route::group(['namespace' => 'WechatFront'], function ($router) {
    $router->get('/wall/{id}', 'WallController@index')->name("wechatfront.index");
    $router->get('/wall/ajaxWallInfo/{wallid}/{lastid}', 'WallController@ajaxWallInfo')->name("wechatfront.ajaxWallInfo");
    $router->get('/wall/draw/{wallid}', 'WallController@draw')->name("wechatfront.wall.draw");
    $router->get('/wall/showqrcode/{id}', 'WallController@showQrCode')->name("wechatfront.wall.showqrcode");
});

Auth::routes();

Route::group(['middleware' => ['auth','permission'],'prefix' => 'admin','namespace' => 'Admins'], function ($router) {
    //首页
    $router->get('/', 'IndexController@index')->name("index");
    //控制台
    $router->get('/console/flushCache', 'ConsoleController@flushCache')->name("console.flushCache");
    //菜单
    $router->resource('menu', 'MenuController');
    //权限
    $router->get('/permission/ajaxIndex', 'PermissionController@ajaxIndex')->name('permission.ajaxIndex');
    $router->resource('permission', 'PermissionController');
    //角色
    $router->get('/role/ajaxIndex', 'RoleController@ajaxIndex')->name('role.ajaxIndex');
    $router->get('/role/auth/{id}', 'RoleController@auth')->name('role.auth');
    $router->post('/role/authpost/{id}', 'RoleController@authpost')->name('role.authpost');
    $router->resource('role', 'RoleController');
    //用户
    $router->get('/user/ajaxIndex', 'UserController@ajaxIndex')->name('user.ajaxIndex');
    $router->post('/user/reset/{id}', 'UserController@resetPsd')->name('user.reset');
    $router->resource('user', 'UserController');
    //个人中心
    $router->get('/personal', 'PersonalController@index')->name('personal.index');
    $router->post('/personal/save', 'PersonalController@save')->name('personal.save');
    $router->get('/personal/psd', 'PersonalController@psd')->name('personal.psd');
    $router->post('/personal/psdsave', 'PersonalController@psdsave')->name('personal.psdsave');
});
//微信控制
Route::group(['middleware' => ['auth','permission'],'prefix' => 'wechatapi','namespace' => 'Wechat'], function ($router) {
    //欢迎词
    $router->get('/welcome/index', 'WelcomeController@index')->name('welcome.index');
    $router->post('/welcome', 'WelcomeController@save')->name('welcome.save');

    //自动回复
    $router->get('/msgrule/ajaxIndex', 'MsgRuleController@ajaxIndex')->name('msgrule.ajaxIndex');
    $router->resource('msgrule', 'MsgRuleController');

    //微信菜单
    $router->get('/wechatmenu/addMenu', 'WechatMenuController@addMenu')->name('wechatmenu.addMenu');
    $router->get('/wechatmenu/delMenu', 'WechatMenuController@delMenu')->name('wechatmenu.delMenu');
    $router->resource('wechatmenu', 'WechatMenuController');

    //微信用户
    $router->get('/wechatuser/ajaxIndex', 'WechatUserController@ajaxIndex')->name('wechatuser.ajaxIndex');
    $router->get('/wechatuser/updateUser', 'WechatUserController@updateUser')->name('wechatuser.updateUser');
    $router->resource('wechatuser', 'WechatUserController');

    //微信墙
    $router->get('/wall/ajaxIndex', 'WallController@ajaxIndex')->name('wall.ajaxIndex');
    $router->get('/wall/createQrCode/{id}', 'WallController@createQrCode')->name('wall.createQrCode');
    $router->resource('wall', 'WallController');
});

Route::any('/wechatvalidate', 'WechatController@serve');


Route::any('/test','TestController@index');
Route::any('/sendmsg','SendMsgController@index');